package com.hrms.config;

import com.hrms.intercept.AdminInterceptor;
import com.hrms.intercept.EmployeeInterceptor;
import com.hrms.intercept.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    // 配置拦截器

    @Autowired
    private UserInterceptor userInterceptor;
    @Autowired
    private EmployeeInterceptor employeeInterceptor;
    @Autowired
    private AdminInterceptor adminInterceptor;

    public void addInterceptors(InterceptorRegistry registry) {
        // 用户端的拦截器
        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");

        // 员工端的拦截器
        registry.addInterceptor(employeeInterceptor).addPathPatterns("/employee/**");

        // 管理员端的拦截器
        registry.addInterceptor(adminInterceptor).addPathPatterns("/admin/**");
    }
}
